/**
 * Created by thinkl on 2017/6/22.
 */
$(function () {
    var app_data = {
        shopping_commodity: {},
    };
    var app = new Vue({
        el: '#shopping_detail',
        data: app_data,
    });

    var com_id = getQueryString('id');
    $.post('/commodity/get_commodity', {commodity_id: com_id}, function (data) {
        var l = JSON.parse(data);
        app_data.shopping_commodity = l.result;
        // var obj = l.result;
        // var html = '<div><span>商品名称:</span>' + obj.name + '</div>' +
        //     '<div><span>商品价格:</span>' + obj.price + '</div>' +
        //     '<div><span>商品优惠:</span>' + obj.preferential + '</div>';
        // $.each(obj.p, function (index, item) {
        //     html += '<div><span>' + item.property + ':</span>';
        //     $.each(item.v, function (index, va) {
        //         html += '<button class="button_small" onclick="">' + va.value + '</button>';
        //     });
        //     html += '</div>'
        // });
        // $('#shopping_commodity').html(html)
    })
});
function add_cart() {
    var com_id = getQueryString('id');
    var com_num = $('input[name=com_num]').val();
    $.post('/shopping_cart/add_shopping_cart', {commodity_id: com_id, com_num: com_num}, function (data) {
        var l = JSON.parse(data);
        alert(l.message)
    })

}
function go_cart() {
    location.href = '/static/shopping_cart/shopping_cart.html'
}